﻿using S7.Net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace thinger.VisionDemo
{
    public partial class Frm摇筛装置 : Form
    {
        Plc siemens;
        public Frm摇筛装置()
        {
            InitializeComponent();
        }

        private void btnPlcConnect_Click(object sender, EventArgs e)
        {
            try
            {


                siemens = new Plc(CpuType.S71200, txtPlcIP.Text, 102, 0, 1);


                // 连接对象
                siemens.Open();
                if (!siemens.IsConnected)
                {
                    labStatus.Text = "连接PLC失败！";
                }
                else
                {
                    labStatus.Text = "连接PLC成功！";
                    //updateTimer.Enabled = true;
                }
            }
            catch
            {
                MessageBox.Show("参数错误，请检查！");
            }
        }

        private void btnPlcDisconnect_Click(object sender, EventArgs e)
        {
            try
            {
                siemens.Close();
                labStatus.Text = "PLC断开连接！";
                //updateTimer.Enabled = false;
            }
            catch
            {
                MessageBox.Show("参数错误，请检查！");
            }
        }
    }
}
